﻿
@model DTOs.InvoiceDTO
           
           <script type="text/javascript">

               function updateAddToCartPartialView() {

                   $('#addToCart').load('AddToCartPartialView');
               }
           </script>

<div id="summaryView">
<table>

<tr><td> &nbsp; Items in Cart:</td></tr>
    
    @using (Ajax.BeginForm("EmptyCard", "ShoppingCart", new {viewfrom = "summary"}, new AjaxOptions() { UpdateTargetId = "summaryView", OnSuccess = "updateAddToCartPartialView", InsertionMode = InsertionMode.Replace, HttpMethod = "post" }))
    {
    <tr>
        <th>Qty</th>
		<th>Product</th>
		<th>Price</th>
		<td>
        <input type="submit" value="Empty Cart" />
        
        </td>
	</tr>
    }

    @using (Ajax.BeginForm("Remove", "ShoppingCart", new {viewfrom = "summary"}, new AjaxOptions() { UpdateTargetId = "summaryView", OnSuccess = "updateAddToCartPartialView", InsertionMode = InsertionMode.Replace, HttpMethod = "post" }))
{
foreach (DTOs.InvoiceItemDTO item in Model.InvoiceItems)
{ 
    <tr>
        <th>@item.Quantity</th>
		<th>@item.ProductName</th>
		<th>@item.Price</th>
		<td>
        
        <input type="submit" value="Remove" />      
        <input type="hidden" name="productId" value="@item.ProductId" />      
        </td>
	</tr>
}
    
}
   
    <tr>
        <th></th>
		<th>Sub Total</th>
		<th>@Model.SubTotal</th>
		<td>
        
        </td>
	</tr>
   

   <tr>
        <th></th>
		<th>Transport Cost</th>
		<th>@Model.ShippingCost</th>
		<td>
        
        </td>
	</tr>

    <tr>
        <th></th>
		<th>Total Cost</th>
		<th>@Model.Total</th>
		<td>
        
        </td>
	</tr>

</table>
</div>